
<template>
  <div class="fillcontain" v-loading="dataListLoading">
    <div v-if="isEdit">
      <p style="font-size: 16px; padding: 20px 0 20px 20px">配置类型</p>
      <el-form
        :model="dataForm2"
        :rules="dataRule"
        ref="divisordataForm"
        @keyup.enter.native="dataFormSubmit()"
      >
        <el-row style="height: 100px; border-bottom: 1px solid #e1e1e1">
          <el-col :span="12">
            <el-form-item
              label="规则导航类型"
              label-width="120px"
              prop="itemType"
            >
              <el-select
                v-model="dataForm2.itemType"
                :disabled="isShow"
                filterable
                clearable
                @change="getitemType"
                placeholder="请选择规则导航类型"
              >
                <el-option
                  v-for="item in responType"
                  :key="item.typeId"
                  :label="item.name"
                  :value="`${item.typeId}`"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <el-form
      v-if="isAdd"
      :inline="true"
      ref="dataForms"
      :model="dataForm"
      class="search_container"
      style="height: 100px"
      :rules="dataFormsrules"
    >
      <el-row style="margin-top: 20px">
        <el-col>
          <el-form-item label="险种代码" prop="riskCode">
            <el-select
              style="width: 200px"
              :disabled="isrisk"
              v-model="dataForm.riskCode"
              filterable
              clearable
              placeholder="请选择"
            >
              <el-option
                v-for="item in riskCodeList"
                :key="item.riskCode"
                :label="item.riskCode"
                :value="item.riskCode"
                @click.native.prevent="getrisktype(item)"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" v-if="!isShow" @click="getcopyInfo()"
              >复制</el-button
            >
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div class="contain1">
      <el-aside width="280px">
        <div class="aside-title">
          <icon-svg :name="'menu'"></icon-svg>
          <p>规则配置导览</p>
        </div>
        <div class="asidemenu">
          <rule-config
            :data="asidemenu"
            ref="ruleConfig"
            :isShow="isShow"
            @editTitile="editTitile"
          ></rule-config>
        </div>
      </el-aside>
      <el-main class="main">
        <div class="main-title">
          <icon-svg :name="'zhedie'"></icon-svg>
          <p>规则详细配置</p>
        </div>
        <div class="contant">
          <div class="cont-text">
            <div class="left" style="display: flex">
              <div class="left-icon">
                <icon-svg :name="'bianji'"></icon-svg>
              </div>
              <span class="gzdy">{{ ruleTitle }}定义</span>
              <span class="canshu" v-if="!isShow" @click="paramConfig()"
                >参数配置</span
              >
            </div>
            <div class="right" style="margin-right: 20px">
              <el-button type="primary" v-if="!isShow" @click="updateAdd()"
                >新增</el-button
              >
            </div>
          </div>
          <div class="cont-data">
            <el-card class="box-card" v-if="isCard">
              <div class="cont">
                <el-form
                  @keyup.enter.native="dySaveSubmit(dyform.addsubdataForm)"
                  :model="dyform"
                  ref="adddataFormdy"
                >
                  <el-col
                    :span="12"
                    v-for="(item, index) in dyform.addsubdataForm"
                    :key="index"
                  >
                    <rules-input v-if="item && item.headType == '0'">
                      <template slot="ruleinput">
                        <el-input
                          disabled
                          v-if="item && item.decisionCode == 'RCODE'"
                          v-model="item.conditionDesc"
                          placeholder="请输入内容"
                        ></el-input>
                        <el-form-item
                          v-else
                          :prop="`addsubdataForm.` + index + `.conditionDesc`"
                          label=""
                          :ref="`${index}RNAME`"
                          :rules="{
                            required: true,
                            message: '请选择规则组名称',
                            trigger: 'change',
                          }"
                        >
                          <el-select
                            v-model="item.conditionDesc"
                            filterable
                            placeholder="请选择"
                          >
                            <el-option
                              v-for="i in ruleNames"
                              :key="i.value"
                              :label="i.label"
                              :value="i.value"
                              @click.native.prevent="
                                changeruleName(item, item.conditionDesc)
                              "
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </template>
                      <template
                        v-if="item && item.decisionCode == 'RCODE'"
                        slot="inputdes"
                      >
                        规则编码
                      </template>
                      <template v-else slot="inputdes"> 规则组名称 </template>
                    </rules-input>
                    <rules-input v-if="item && item.headType == '1'">
                      <template v-if="item && item.iszhixing" slot="ruleinput">
                        <el-form-item label="">
                          <el-select
                            v-model="item.isExcute"
                            :disabled="item.disabled"
                            filterable
                            clearable
                            placeholder="请选择"
                          >
                            <el-option
                              v-for="i in excuteTypes"
                              :key="i.value"
                              :label="i.label"
                              :value="i.value"
                              @click.native="
                                changeExeType(
                                  item,
                                  index,
                                  dyform.addsubdataForm
                                )
                              "
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </template>
                      <template
                        v-if="item && item.conditionType == '4' && item.divisor"
                        slot="ruleinput"
                      >
                        <!-- 规则因子 非方法 且文本类型 则是输入框-->
                        <el-form-item label="">
                          <el-input
                            v-if="
                              item.divisor.valueType === '2' &&
                              item.divisor.divisorType === '0' &&
                              item.divisor.itemValueType === '1'
                            "
                            v-model="item.rightValue"
                            @blur="insertV('41', item)"
                            :disabled="item.disabled"
                            placeholder="文本值"
                          ></el-input>
                          <a
                            class="cont-a"
                            v-if="item.divisor && item.divisor.isConfig === '1'"
                            @click="configCont(item, showindex, index)"
                            >配置</a
                          >
                        </el-form-item>
                        <!-- 规则因子 非方法 且枚举类型 则是下拉框-->
                        <!-- :prop="dyform.addsubdataForm[index].rightValue" -->
                        <el-form-item label="">
                          <el-select
                            v-if="
                              item.divisor.divisorType === '0' &&
                              item.divisor.valueType === '2' &&
                              item.divisor.itemValueType === '2'
                            "
                            :disabled="item.disabled"
                            v-model="item.rightValue"
                            filterable
                            clearable
                            placeholder="请选择条件"
                          >
                            <el-option
                              v-for="i in enumList[`${item.divisor.id}list`]"
                              :key="i.enumCode"
                              :label="i.label"
                              :value="i.enumCode"
                              @click.native="insertV('42', item, i)"
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                        <!-- 规则因子 非方法 且模型类型 则是模型-->
                        <!-- :prop="item.rightEntityId" -->
                        <el-form-item label="">
                          <el-select
                            v-if="
                              item.divisor.divisorType === '0' &&
                              item.divisor.valueType === '2' &&
                              item.divisor.itemValueType === '3'
                            "
                            :disabled="item.disabled"
                            v-model="item.rightEntityId"
                            filterable
                            clearable
                            placeholder="请选择模型"
                          >
                            <el-option
                              v-for="i in checkEntity"
                              :key="i.entityId"
                              :label="i.entityName"
                              :value="i.entityId"
                              @click.native="insertV('43', item, i)"
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                        <el-select
                          v-if="
                            item.divisor.divisorType === '0' &&
                            item.divisor.valueType === '2' &&
                            item.divisor.itemValueType === '3'
                          "
                          :disabled="item.disabled"
                          v-model="item.rightProperty"
                          filterable
                          clearable
                          placeholder="请选择属性"
                        >
                          <el-option
                            v-for="i in childList[`${item.rightEntityId}list`]"
                            :key="i.itemId"
                            :label="i.label"
                            :value="i.itemId"
                            @click.native="insertV('44', item, i)"
                          >
                          </el-option>
                        </el-select>
                        <el-col
                          :span="24"
                          v-if="
                            item.divisor.divisorType === '1' &&
                            item.divisorMethodParams
                          "
                        >
                          <el-col
                            :span="12"
                            v-for="(p, index) in item.divisorMethodParams"
                            :key="index"
                          >
                            <el-col>
                              <el-select
                                :disabled="item.disabled"
                                v-if="p.valueType === '2'"
                                v-model="p.name"
                                filterable
                                placeholder="值类型"
                              >
                                <el-option
                                  v-for="itemsub in item.divisormethodEnum[
                                    index
                                  ]"
                                  :key="itemsub.value"
                                  :label="itemsub.label"
                                  :value="itemsub.value"
                                  @click.native="insertV('45', item, p)"
                                >
                                </el-option>
                              </el-select>
                              <el-input
                                v-else
                                :disabled="item.disabled"
                                v-model="p.name"
                                @blur="insertV('45', item, p)"
                                :placeholder="p.desc"
                              ></el-input>
                              <span v-if="!isShow">
                                <a
                                  class="cont-a"
                                  v-if="
                                    item.divisor &&
                                    item.divisor.isConfig === '1'
                                  "
                                  @click="configCont(item, showindex, index)"
                                  >配置</a
                                >
                              </span>
                            </el-col>
                          </el-col>
                        </el-col>
                      </template>
                      <template
                        v-if="item && item.headType == '1'"
                        slot="inputdes"
                      >
                        {{ item["conditionDesc"] + "(条件)" }}
                      </template>
                    </rules-input>
                    <rules-input v-if="item && item.headType == '2'">
                      <template v-if="item && item.iszhixing" slot="ruleinput">
                        <el-select
                          :disabled="item.disabled"
                          v-model="item.isExcute"
                          filterable
                          clearable
                          placeholder="请选择"
                        >
                          <el-option
                            v-for="i in excuteTypes"
                            :key="i.value"
                            :label="i.label"
                            :value="i.value"
                            @click.native="
                              changeExeType(item, index, dyform.addsubdataForm)
                            "
                          >
                          </el-option>
                        </el-select>
                      </template>
                      <!-- 规则因子 -->
                      <template
                        v-if="item && item.conditionType == '4' && item.divisor"
                        slot="ruleinput"
                      >
                        <el-input
                          :disabled="item.disabled"
                          v-if="
                            item.divisor.valueType === '2' &&
                            item.divisor.divisorType === '0' &&
                            item.divisor.itemValueType === '1'
                          "
                          v-model="item.rightValue"
                          @blur="insertV('41', item)"
                          placeholder="文本值"
                        ></el-input>
                        <!-- 规则因子 非方法 且枚举类型 则是下拉框-->
                        <el-select
                          :disabled="item.disabled"
                          v-if="
                            item.divisor.divisorType === '0' &&
                            item.divisor.valueType === '2' &&
                            item.divisor.itemValueType === '2'
                          "
                          v-model="item.rightValue"
                          filterable
                          clearable
                          placeholder="请选择动作"
                        >
                          <el-option
                            v-for="i in actionEnumList[
                              `${item.divisor.id}list`
                            ]"
                            :key="i.enumCode"
                            :label="i.label"
                            :value="i.enumCode"
                            @click.native="insertV('42', item, i)"
                          >
                          </el-option>
                        </el-select>
                        <!-- 规则因子 非方法 且模型类型 则是模型-->
                        <el-select
                          :disabled="item.disabled"
                          v-if="
                            item.divisor.divisorType === '0' &&
                            item.divisor.valueType === '2' &&
                            item.divisor.itemValueType === '3'
                          "
                          v-model="item.rightEntityId"
                          filterable
                          clearable
                          placeholder="请选择模型"
                        >
                          <el-option
                            v-for="i in checkEntity"
                            :key="i.entityId"
                            :label="i.entityName"
                            :value="i.entityId"
                            @click.native="insertV('43', item, i)"
                          >
                          </el-option>
                        </el-select>
                        <!--  -->
                        <el-select
                          :disabled="item.disabled"
                          v-if="
                            item.divisor.divisorType === '0' &&
                            item.divisor.valueType === '2' &&
                            item.divisor.itemValueType === '3'
                          "
                          v-model="item.rightProperty"
                          filterable
                          clearable
                          placeholder="请选择属性"
                        >
                          <el-option
                            v-for="i in childList[`${item.rightEntityId}list`]"
                            :key="i.itemId"
                            :label="i.label"
                            :value="i.itemId"
                            @click.native="insertV('44', item, i)"
                          >
                          </el-option>
                        </el-select>
                        <!-- 规则因子 方法-->
                        <el-col
                          :span="24"
                          v-if="
                            item.divisor.divisorType === '1' &&
                            item.divisorMethodParams
                          "
                        >
                          <el-col
                            :span="12"
                            v-for="(p, index) in item.divisorMethodParams"
                            :key="index"
                          >
                            <el-col :span="12">
                              <el-input
                                :disabled="item.disabled"
                                @blur="insertV('45', item, p)"
                                v-if="p.valueType != '2'"
                                v-model="p.name"
                                :placeholder="p.desc"
                              ></el-input>
                              <el-select
                                :disabled="item.disabled"
                                v-if="p.valueType === '2'"
                                v-model="p.name"
                                filterable
                                placeholder="值类型"
                              >
                                <el-option
                                  v-for="itemsub in item.divisormethodEnum[
                                    index
                                  ]"
                                  :key="itemsub.value"
                                  :label="itemsub.label"
                                  :value="itemsub.value"
                                  @click.native="insertV('45', item, p)"
                                >
                                </el-option>
                              </el-select>
                              <span v-if="!isShow">
                                <a
                                  class="cont-a"
                                  v-if="
                                    item.divisor &&
                                    item.divisor.isConfig === '1'
                                  "
                                  @click="configCont(item, showindex, index)"
                                  >配置</a
                                >
                              </span>
                            </el-col>
                          </el-col>
                        </el-col>
                      </template>
                      <template
                        v-if="item && item.headType == '2'"
                        slot="inputdes"
                      >
                        {{ item["conditionDesc"] + "(动作)" }}
                      </template>
                    </rules-input>
                  </el-col>
                </el-form>
              </div>
              <div class="dingyi-footer" v-if="!isShow">
                <el-button
                  type="info" plain
                   @click="dySaveSubmit(dyform.addsubdataForm)"
                  >保存</el-button
                >
                <el-button @click="isCard = false">取消</el-button>
              </div>
            </el-card>
            <!-- </div> -->
            <!-- 列表 -->
            <edit-table
              v-if="istable"
              :isShow="isShow"
              :tableDatas="tableDatas"
              :conditionList="conditionList"
              @changeisCard="changeisCard"
              @changeeditRow="changeeditRow"
              @delDecision="delDecision"
            >
            </edit-table>
          </div>
        </div>
      </el-main>
    </div>
    <div class="content-footer">
      <el-button :plain="true" type="info" v-if="!isShow" @click="contentSubmit()"
        >确定</el-button
      >
      <el-button @click="toList()">返回</el-button>
    </div>
    <!-- 参数配置 -->
    <el-dialog
      id="cofginpz"
      title="参数配置"
      :close-on-click-modal="false"
      width="60%"
      :visible.sync="configvisible"
    >
      <div class="edit_dev" style="text-align: center">
        <el-transfer
          style="text-align: left; display: inline-block"
          filterable
          v-model="tranvalue"
          :right-default-checked="tranrightvalue"
          :props="{
            key: 'id',
            label: 'conditionDesc',
          }"
          :titles="['可选配置项', '已选配置项']"
          :button-texts="['到左边', '到右边']"
          @right-check-change="handleChange"
          :data="trandata"
        >
        </el-transfer>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="info" plain @click="configSubmit()">保存</el-button>
        <el-button @click="configvisible = false">取消</el-button>
      </span>
    </el-dialog>
    <!-- 复制 -->
    <el-dialog
      title="复制"
      :close-on-click-modal="false"
      width="30%"
      :visible.sync="copyvisible2"
    >
      <el-form
        :inline="true"
        :model="copydataForm2"
        :rules="copyRules"
        class="search_container"
        label-width="120px"
        ref="copyData"
      >
        <el-col>
          <el-form-item label="险种代码" prop="baseRiskCode">
            <el-select
              v-model="copydataForm2.baseRiskCode"
              filterable
              clearable
              placeholder="请选择"
            >
              <el-option
                v-for="item in riskCodeList"
                :key="item.riskCode"
                :label="item.riskCode"
                :value="item.riskCode"
                @click.native.prevent="checkriskCode(item)"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button :plain="true" type="info" @click="copySubmit2()">确定</el-button>
        <el-button @click="copyvisible2 = false">取消</el-button>
      </span>
    </el-dialog>

    <!-- 公式配置 -->
    <formula
      ref="formula"
      @getFormulainfo="getFormulainfo"
      :formulatitle="formulatitle"
    ></formula>
  </div>
</template>

<script>
import {
  baseHeder,
  getByTaskHeder,
  riskList,
  checkRuleGroup,
  updateComplete,
  saveRiskRule,
  copyRiskRuleInfo, //复制
} from "@/api/ruleConfig/groupInfo";
import { entityList, entityItemList } from "@/api/baseConfig/entity";
import { ruleRiskMenu, listMenuType } from "@/api/rulesmenu";
import { treeDataTranslate, getCity, recursion } from "@/utils";
import insure from "@/api/insure";
import constant from "@/api/constant";
import {
  getActionData,
  listActionDivisorData,
} from "@/api/baseConfig/actionDivisor";
import {
  getData,
  getEnum,
  listConditionDivisorData,
} from "@/api/baseConfig/conditionDivisor";
import editTable from "./edit-table.vue";
export default {
  data() {
    return {
      isEditLine: false, //是否修改行
      isaddLine: false, //是否新增行
      initHead: [], //添加表头编码、名称
      ruleNames: [], //规则名称组
      ruleparamsData: [], //配置过滤
      groupIdentifys: [], //过滤出的规则组id
      isCard: true,
      istable: false,
      conditionList: [],
      tableDatas: [],
      configData: {},
      configIndex: 0,
      // 公式配置
      formulatitle: "医疗险公式配置",
      checkEntity: [], //模型
      FormuladataForm: {},
      paramindex: 0, //参数配置
      // 复制
      copyvisible2: false,
      copydataForm2: {
        baseRiskCode: "",
      },
      copyRules: {
        baseRiskCode: [
          { required: true, message: "请选择险种代码", trigger: "change" },
        ],
      },
      isShow: false,
      isrisk: false,
      dyform: {
        addsubdataForm: [],
      },
      headdata: [],
      headdatainit: [],
      bodydata: [],
      delList: [],
      trandata: [],
      tranvalue: [],
      initdataform: [],
      iszhixing: false,
      riskCodeList: [],
      entitysProperties: [], //所有模型
      conditionDivisorList: [], //条件配置
      actionDivisorList: [], //动作配置
      enumList: {}, //条件枚举列表
      actionEnumList: {}, //动作枚举列表
      tranrightvalue: [],
      dataForm2: {
        itemType: "", //单一
      },
      childList: {},
      excuteTypes: constant.ruleConfig.excuteTypes,
      ruleTitle: "",
      isEdit: true,
      isAdd: true,
      paramData: {},
      asidemenu: [],
      showAll: true,
      configvisible: false,
      taskinfo2: {},
      checktaskarry: [],
      btnBoolean: false,
      allGroupInfo: insure.insurenceTyoe, // 险种类型
      responType: [],
      loading: false,
      templateStr: "",
      showVisbale: false,
      isComplete: "",
      dataForm: {
        riskCode: "",
        fullName: "",
        itemType: "",
        taskNo: "",
        groupIdentify: "",
        menuId: "",
      },
      dataRule: {
        // qualityName: [{ validator: validateName, trigger: "blur" }],
        // qualityIdentify: [{ validator: validateIdentify, trigger: "blur" }],
      },
      dataFormsrules: {
        riskCode: [
          {
            required: true,
            message: "请选择险种代码！",
            trigger: "blur",
          },
        ],
        // qualityIdentify: [{ validator: validateIdentify, trigger: "blur" }],
      },
      echoMenulds: [], //已配置菜单
      dataList: [],
      dataListLoading: false,
      defaultProps: {
        children: "children",
        label: "label",
      },
      initadd: {
        RCODE: {
          clashVersion: null,
          conditionDesc: "",
          conditionExpression: "",
          conditionMethodType: null,
          conditionType: null,
          creTime: "2021-07-06T05:43:27.000+0000",
          creUserId: "sxm",
          decisionCode: "RCODE",
          decisionExp: null,
          divisorId: null,
          groupIdentify: "",
          headType: "0",
          id: null,
          isEffect: "1",
          isExcute: "Y",
          lastUpdateId: "admin",
          lastUpdateTime: "2021-07-06T07:11:02.000+0000",
          leftEntityId: null,
          leftProperty: null,
          methodName: null,
          methodParams: null,
          remark: null,
          rightEntityId: null,
          rightProperty: null,
          rightValue: null,
          rowIndex: null,
          sysbol: null,
        },
        RNAME: {
          clashVersion: null,
          conditionDesc: "",
          conditionExpression: "",
          conditionMethodType: null,
          conditionType: null,
          creTime: "2021-07-06T05:43:27.000+0000",
          creUserId: "sxm",
          decisionCode: "RNAME",
          decisionExp: null,
          divisorId: null,
          groupIdentify: "",
          headType: "0",
          id: null,
          isEffect: "1",
          isExcute: "Y",
          lastUpdateId: "admin",
          lastUpdateTime: "2021-07-06T07:11:02.000+0000",
          leftEntityId: null,
          leftProperty: null,
          methodName: null,
          methodParams: null,
          remark: null,
          rightEntityId: null,
          rightProperty: null,
          rightValue: null,
          // rowIndex: null,
          sysbol: null,
        },
      },
    };
  },

  //利用计算属性
  computed: {
    taskinfo() {
      return this.$store.state.checktaskInfo;
    },
  },
  //监听执行
  watch: {
    taskinfo: {
      handler: function (newVal, oldVal) {
        this.taskinfo2 = newVal;
        // this.dataForm1.taskNo
        this.dataForm.taskNo = this.taskinfo2.taskNo;
        // console.log(this.taskinfo2.taskNo, "this.taskinfo2.taskNo");
        if (newVal.status == "1") {
        } else {
          // this.$message.warning("该任务已发布，不能新增或编辑!");
        }
      },
      deep: true,
    },
  },
  mounted() {
    this.getEntityProperties();
    this.getriskList();
    // 编辑/查看
    if (this.$route.params.id) {
      this.getlistMenuType();
      this.isrisk = true;
      this.isEdit = true;
      let data = JSON.parse(this.$route.query.data);
      this.dataForm.prodTaskNo = data.taskNo;
      this.dataForm2.riskType = data.riskType;
      if (this.$route.query.isShow) {
        this.isShow = this.$route.query.isShow;
      }
      this.dataForm.riskCode = data.riskCode;
      this.dataForm2.itemType = data.itemType;
    } else {
      this.isEdit = false;
    }
    // 新增
    if (this.$route.query.dataForm2) {
      let dataForm2 = JSON.parse(this.$route.query.dataForm2);
      this.taskinfo2.taskNo = this.$store.state.checktaskInfo.taskNo;
      this.dataForm2.itemType = dataForm2.itemType;
    }
    this.geteditList(this.dataForm2.itemType);
    this.taskinfo2 = this.$store.state.checktaskInfo;
  },

  components: {
    editTable,
  },
  methods: {
    getitemType(item) {
      this.geteditList(item);
      // console.log(item, "item");
    },
    changeruleName(item, groupIdentify) {
      if (groupIdentify) {
        item.groupIdentify = groupIdentify;
        this.groupIdentifys = [groupIdentify];
        let configData = [];
        if (this.conditionList.length) {
          this.headdatainit.forEach((el) => {
            if (el.decisionCode != "RNAME" && el.decisionCode != "RCODE") {
              if (el.groupIdentify == groupIdentify) {
                configData.push(el);
              }
            }
          });
        } else {
          // 新增
          this.paramData.forEach((el) => {
            if (el.groupIdentify == this.groupIdentifys) {
              configData = el.baseList;
            }
          });
        }
        this.dyform.addsubdataForm.forEach((r) => {
          if (r.decisionCode != "RCODE") {
            r.disabled = true;
          }
          if (r.decisionCode != "RNAME") {
            configData.forEach((t) => {
              if (r.headType === t.headType && r.divisorId === t.divisorId) {
                r.disabled = false;
              }
            });
          } else {
            r.disabled = false;
          }
          if (r.disabled) {
            r.isExcute = "";
            r.rightValue = "";
            r.rightEntityId = "";
            r.rightProperty = "";
          }
        });
      } else {
        this.$message.error("该规则组没有参数");
        return;
      }
    },
    // 获取类型
    getlistMenuType() {
      listMenuType({}).then(({ data }) => {
        if (data && data.resultCode === 0) {
          this.responType = data.data;
        }
      });
    },
    // 获取菜单
    geteditList(id) {
      this.asidemenu = [];
      ruleRiskMenu(id).then(({ data }) => {
        data.data.menuList.forEach((e) => {
          if (e.type === "0") {
            e.icon = "typemenu";
          } else if (e.type === "1") {
            e.icon = "wenhao";
          }
        });
        let asidemenu = treeDataTranslate(data.data.menuList, "menuId");
        this.getcheckRuleGroup();
        this.asidemenu = asidemenu;
        let result = recursion(this.asidemenu, "type", "1");
        // console.log(result, "result");
        this.ruleTitle = result.menuName;
        if (result.groupIdentifys) {
          this.dataForm.groupIdentify = result.groupIdentifys.split(",");
          this.dataForm.menuId = result.menuId;
        }
        this.$nextTick(() => {
          // console.log(this.asidemenu, "222");
          this.$refs.ruleConfig.$refs.tree.setCurrentKey(`${result.menuId}`);
          this.dataForm.menuId = result.menuId;
          this.inittree();
          this.initdata();
        });
        // if (this.asidemenu[0].type === "1") {

        // } else if (
        //   this.asidemenu[0].children &&
        //   this.asidemenu[0].children.length
        // ) {
        //   this.fun1();
        // let initset = this.asidemenu[0].children.find (e => e.type ==='1')
        //   // console.log(initset,'initset');
        //         this.$nextTick(() => {
        //   // console.log(this.asidemenu, "222");
        //   this.$refs.ruleConfig.$refs.tree.setCurrentKey(`${initset.menuId}`);
        //   this.dataForm.menuId = initset.menuId;
        // });
        // }
      });
    },

    // 编辑
    changeeditRow(value) {
      this.isEditLine = true;
      this.isCard = true;
      this.groupIdentifys[0] = value["RNAME"].groupIdentify;
      this.dyform.addsubdataForm = this.getformdata(
        this.conditionList,
        value,
        "edit"
      );
    },
    // 复制
    changeisCard(value) {
      // console.log(value, "value");
      this.isaddLine = true;
      this.isCard = true;
      this.groupIdentifys = [value["RNAME"].groupIdentify];
      this.dyform.addsubdataForm = this.getformdata(
        this.conditionList,
        value,
        "add"
      );
    },
    inittree() {
      this.$nextTick(() => {
        let params = {
          groupIdentify: this.dataForm.groupIdentify,
          conditionDesc: "",
          taskNo: this.taskinfo2.taskNo,
        };
        this.getparamConfigData(params);
      });
    },
    // 获取配置信息值
    getFormulainfo(data) {
      this.dyform.addsubdataForm[this.configIndex].forEach((item) => {
        if (item.decisionCode === this.configData.decisionCode) {
          // 41
          if (
            item.divisor.valueType === "2" &&
            item.divisor.divisorType === "0" &&
            item.divisor.itemValueType === "1"
          ) {
            item.rightValue = data.expression;
            item.descData[0] = { k: data.expression, v: data.expression };
          }
          // 42
          if (
            item.divisor.divisorType === "0" &&
            item.divisor.valueType === "2" &&
            item.divisor.itemValueType === "2"
          ) {
            item.rightValue = data.expression;
            // item.descData[0] = { k: data.expression, v: data.expression };
            item.isExcute = data.expression || "Y";
          }
          // 43
          if (
            item.divisor.divisorType === "0" &&
            item.divisor.valueType === "2" &&
            item.divisor.itemValueType === "3"
          ) {
            item.rightEntityId = data.expression;
            if (item.descData[0] && item.descData[0].v) {
              item.descData[0].v = data.expression;
            }
          }
          // 44
          if (
            item.divisor.divisorType === "0" &&
            item.divisor.valueType === "2" &&
            item.divisor.itemValueType === "3"
          ) {
            if (item.descData[1] && item.descData[1].v) {
              item.rightProperty = data.expression;
              item.descData[1].v = data.expression;
            }
          }
          // 45
          if (item.divisor.divisorType === "1" && item.divisorMethodParams) {
            item.divisorMethodParams[this.paramindex].name = data.expression;
            item.descData[this.paramindex] = {
              k: data.expression,
              v: data.expression,
            };
          }
          item.remark = item.descData;
        }
      });

      // console.log(item);
    },
    expand(id, data, currid) {
      // 展开
      this.$set(data, "isShow", !data.isShow);
      // console.log(data);
    },
    configCont(data, index, paramindex) {
      // console.log(data, index, paramindex, "data");
      this.configData = data;
      this.paramindex = paramindex;
      this.configIndex = index;
      this.formulatitle = data.conditionDesc;
      this.$refs.formula.Formulavisible = true;

      this.$refs.formula.dataForm = {
        formulaType: "3",
        expression: "",
        desc: "",
      };
    },
    initdata() {
      Promise.all([this.fun1()]).then((res) => {
        if (this.$route.params.id) {
          this.fun2();
        }
      });
    },
      fun1() {
      return new Promise((resolve, reject) => {
        /* 你的逻辑代码 */
        let params = {
          is_effect: "1",
        };
        listConditionDivisorData(params).then((res) => {
          this.conditionDivisorList = res.data.data;
          resolve();
        });
        listActionDivisorData(params).then((res) => {
          this.actionDivisorList = res.data.data;
        });
      });
    },
    fun2() {
      return new Promise((resolve, reject) => {
        // console.log(this.dataForm);
        let param = {
          taskNo: this.taskinfo2.taskNo || "",
          riskCode: this.dataForm.riskCode,
          groupIdentify: this.dataForm.groupIdentify,
        };
        this.getList(param, "init");
        resolve();
      });
    },
    // 重置
    resetrule() {
      this.dyform.addsubdataForm.forEach((e) => {
        if (e.headType === "0" && e.decisionCode === "RNAME") {
          e.conditionDesc = "";
        }
      });
      this.dyform.addsubdataForm = [];
      this.headdata = [];
      this.bodydata = [];
      this.tableDatas = [];
      this.conditionList = [];
      this.headdatainit = [];
    },
    // 查询列表
    async getList(param, init) {
      let res = await getByTaskHeder(param);
      // if (init) {
      //   this.inittree();
      // }
      this.resetrule();
      if (res.data.data) {
        let data = res.data.data;
        let header = data.header;
        this.headdatainit = header.slice(0);
        this.headdata = header.slice(0);
        header.forEach((e) => {
          if (e.decisionCode == "RNAME") {
            e.divisorIdentify = "RNAME";
          }
          if (e.decisionCode == "RCODE") {
            e.divisorIdentify = "RCODE";
          }
        });
        header = insure.quchong(header, "divisorIdentify");

        let addsubdataForm = [];
        let info = data.info;
        let body = [];
        this.ruleNames = [];
        info.forEach((ele) => {
          if (ele) {
            this.ruleNames.push({
              label: ele.groupName,
              value: ele.groupIdentify,
            });
            body = body.concat(ele.body);
          }
        });
        let tableDatas = [];
        body.forEach((element, index) => {
          tableDatas[index] = {};
          for (const key2 in element) {
            if (key2 === "RCODE" || key2 === "RNAME") {
              element[key2]["divisorIdentify"] = key2;
              tableDatas[index][key2] = element[key2];
            } else {
              if (key2 && element[key2] && element[key2]["divisorIdentify"]) {
                let divisorIdentifyw = element[key2]["divisorIdentify"];
                tableDatas[index][divisorIdentifyw] = element[key2];
              }
            }
          }
        });
        if (tableDatas.length) {
          this.bodydata = body.slice(0);
          if (tableDatas.length <= 1) {
            this.istable = false;
            this.isCard = true;
            // this.initdataform = JSON.parse(JSON.stringify(addsubdataForm));
          } else {
            this.istable = true;
            this.isCard = false;
          }
          let datae = JSON.parse(JSON.stringify(tableDatas[0]));
          addsubdataForm = this.getformdata(header, datae);
          this.dyform.addsubdataForm = addsubdataForm;
          this.tableDatas = tableDatas;
          this.tableDatas.forEach((k) => {
            for (const key2 in k) {
              if (key2 === "RNAME") {
                let groupIdentify = k[key2].groupIdentify;
                k[key2].conditionDesc = constant.getLabel(
                  groupIdentify,
                  this.ruleNames
                );
              }
            }
          });
          this.conditionList = header;
        } else {
          this.isCard = true;
          this.istable = false;
          addsubdataForm = this.getformdata(header, []);
          this.dyform.addsubdataForm = addsubdataForm;
        }
      } else {
        this.istable = false;
        this.isCard = true;
      }
      // console.log(this.dyform.addsubdataForm, "11");
      // });
    },
    // body转换成tables

    // 数据转换成表单
    getformdata(head, e, value) {
      // console.log(head, e, value, "head, e, value");
      let addsubdataForm = [];
      let datae = JSON.parse(JSON.stringify(e));
      head.forEach((item) => {
        if (item) {
          let dataForm = {};
          if (datae[item.divisorIdentify]) {
            dataForm = this.setInitData(
              datae[item.divisorIdentify],
              "changecard"
            );
            // console.log(dataForm, "dataForm");
            if (dataForm && dataForm.remark) {
              dataForm["descData"] = new Array();
              dataForm["descData"] = JSON.parse(dataForm.remark);
            }
            if (value === "add") {
              dataForm.id = null;
              dataForm.rowIndex = null;
            }
            if (item && item.conditionDesc) {
              if (
                item.decisionCode != "RNAME" &&
                item.decisionCode != "RCODE"
              ) {
                dataForm["conditionDesc"] = item.conditionDesc;
              }
            }
            dataForm.disabled = false;
          } else {
            if (item.divisorIdentify != "RCODE") {
              dataForm = JSON.parse(
                JSON.stringify(this.setInitData(item, "noquest"))
              );
              // console.log(dataForm);
              dataForm = this.getparamconfig(dataForm);
              dataForm.disabled = true;
              // if (value == "edit" || value == "add") {
              if (e["RNAME"]) {
                if (dataForm.groupIdentify === e["RNAME"].groupIdentify) {
                  dataForm.disabled = false;
                }
              }
              // }
              this.$nextTick(() => {
                // 初始化表单
                dataForm.descData = new Array();
                if (value != "edit") {
                  dataForm.id = null;
                }
                dataForm.isExcute = "";
                dataForm.rightValue = "";
                dataForm.rightEntityId = "";
                dataForm.rightProperty = "";
                // data.descData = JSON.parse(data.remark);
                // console.log(dataForm, "22");
              });
            }
          }
          if (item.isRelatetionCrtable == "1") {
            dataForm.disabled = true;
          }
          if (value === "add") {
            if (item.divisorIdentify != "RCODE") {
              addsubdataForm.push(dataForm);
            }
          } else {
            addsubdataForm.push(dataForm);
          }
        }
      });
      addsubdataForm = this.handleaddsubdataForm(addsubdataForm);
      // console.log(addsubdataForm, "addsubdataForm");
      return addsubdataForm;
    },
    // 险种规则配置样式回显查询
    getcheckRuleGroup() {
      let param = {
        itemType: this.dataForm2.itemType,
        taskNo: this.taskinfo2.taskNo || "",
        riskCode: this.dataForm.riskCode,
      };
      checkRuleGroup(param).then((res) => {
        // console.log(res, "res");
        if (res.data.data) {
          let data = res.data.data;
          this.echoMenulds = [];
          if (data.length) {
            data.forEach((e) => {
              this.echoMenulds.push(e.menuId);
            });
            this.dataForm2.id = data[0].riskId;
          }
          this.asidemenu = getCity(this.echoMenulds, this.asidemenu);
          // console.log(this.echoMenulds, this.asidemenu, "33");
        }
      });
    },
    getcopyInfo() {
      this.copyvisible2 = true;
    },
    // 险种代码
    getrisktype(item) {
      // console.log(item);
      this.dataForm2.riskType = item.riskType;
      // console.log(this.dataForm2.riskType, " this.dataForm2.riskType");
    },
    // 复制
    copySubmit2() {
      // console.log(this.copydataForm2, "copydataForm2");
      this.$refs["copyData"].validate((valid) => {
        if (valid) {
          this.getCopyRiskRule();
        } else {
          return false;
        }
      });
    },
    // 复制接口
    getCopyRiskRule() {
      let param = {
        taskNo: this.taskinfo2.taskNo,
        prodTaskNo: this.dataForm.prodTaskNo || "",
        baseRiskCode: this.copydataForm2.baseRiskCode,
        riskCode: this.dataForm.riskCode,
        itemType: `${this.dataForm2.itemType}`,
        id: `${this.$route.params.id || ""}`,
      };
      copyRiskRuleInfo(param).then((res) => {
        if (res.data.resultCode === 0) {
          this.$message.success("复制成功！");
          let param = {
            groupIdentify: this.dataForm.groupIdentify,
            taskNo: this.taskinfo2.taskNo || "",
            riskCode: this.dataForm.riskCode,
          };
          this.getList(param);
          this.copyvisible2 = false;
        } else {
          this.$message.error(res.data.resultMsg);
        }
      });
    },
    checkriskCode(data) {},
    // 获取险种信息
    getriskList() {
      riskList({}).then((res) => {
        this.riskCodeList = res.data.data;
      });
    },
    inputChange() {
      this.$forceUpdate();
    },
    // 表头是否有规则编码、规则名称
    getheadcode(headdata, initadd) {
      for (const key3 in initadd) {
        let flag = false;
        for (let i = 0; i < headdata.length; i++) {
          if (headdata[i] && headdata[i].decisionCode) {
            if (headdata[i].decisionCode == key3) {
              flag = true;
            }
          }
        }
        if (!flag) {
          headdata.unshift(initadd[key3]);
        }
      }
      // console.log(this.headdata);
    },
    // 规则定义保存
    dySaveSubmit(data, delList2) {
      // console.log(data, "22");
      this.isEditLine = false;
      this.isaddLine = false;
      this.$refs["dataForms"].validate((valid) => {
        if (valid) {
          if (this.dyform.addsubdataForm.length) {
            this.$refs["adddataFormdy"].validate((valid) => {
              if (valid) {
                let delList = [];
                if (delList2) {
                  delList = delList2;
                }
                // 有无规则编码信息
                if (data.length) {
                  for (const key2 in this.initadd) {
                    let flag = false;
                    for (let i = 0; i < data.length; i++) {
                      data[i].remark = data[i].descData;
                      if (data[i].decisionCode == key2) {
                        flag = true;
                      }
                    }
                    if (!flag) {
                      data.unshift(this.initadd[key2]);
                    }
                  }
                } else {
                  data[1] = this.initadd["RCODE"];
                }
                let headdata = [];
                let headType0 = [];
                // 处理表头数据
                if (this.conditionList.length) {
                  headdata = this.conditionList.slice(0);
                } else {
                  headdata = JSON.parse(JSON.stringify(this.headdata));
                }
                this.getheadcode(headdata, this.initadd);
                // // 表头是否有规则编码、规则名称
                if (this.$route.params.id) {
                  let rowIndex = data[0].rowIndex;
                  data.forEach((W) => {
                    W.rowIndex = rowIndex;
                  });
                }
                let riskInfo = {
                  id: this.dataForm2.id,
                  riskCode: this.dataForm.riskCode,
                  taskNo: this.taskinfo2.taskNo,
                  itemType: this.dataForm2.itemType,
                };
                let datae;
                // 处理values数据
                let values = [];
                if (delList2) {
                  datae = [];
                } else {
                  datae = JSON.parse(JSON.stringify(data));
                }
                let groupIdentify = "";
                // 获取当前行规则组标识
                datae.forEach((des) => {
                  if (des.decisionCode === "RNAME") {
                    groupIdentify = des.groupIdentify;
                  }
                });
                datae.forEach((e) => {
                  if (
                    e.decisionCode == "RCODE" ||
                    e.groupIdentify === groupIdentify
                  ) {
                    values.push(e);
                  }
                });
                // console.log(
                //   values,
                //   this.conditionList,
                //   this.headdata,
                //   "addsubdataForm"
                // );
                headdata.forEach((item) => {
                  values.forEach((des) => {
                    if (des.divisorIdentify === item.divisorIdentify) {
                      // console.log("222");
                      this.setValueData(des);
                    }
                    des.groupIdentify = groupIdentify;
                  });
                  if (item.headType === "0") {
                    if (this.echoMenulds.indexOf(this.dataForm.menuId) === -1) {
                      item.groupIdentify = groupIdentify;
                    }
                    item.divisorIdentify = null;
                    if (item.decisionCode === "RCODE") {
                      headType0.push(item);
                    }
                  }
                });
                // console.log(values, "values");
                if (!this.conditionList.length) {
                  let initHead = [];
                  // console.log(this.ruleNames);
                  if (groupIdentify) {
                    this.ruleNames.forEach((R) => {
                      if (R.value != groupIdentify) {
                        initHead.push(R.value);
                      }
                    });
                  }
                  // console.log(initHead, headType0, "initHead");
                  if (initHead.length > 0 && headType0.length === 1) {
                    for (let i = 0; i < initHead.length; i++) {
                      let initadd = JSON.parse(JSON.stringify(this.initadd));
                      initadd.RCODE.groupIdentify = initHead[i];
                      initadd.RNAME.groupIdentify = initHead[i];
                      headdata.unshift(initadd.RCODE);
                      headdata.unshift(initadd.RNAME);
                    }
                  }
                } else {
                  this.headdatainit.forEach((t1) => {
                    let flag = false;
                    headdata.forEach((t2) => {
                      if (t1.id === t2.id) {
                        t2.groupIdentify = t1.groupIdentify;
                        flag = true;
                      }
                    });
                    if (!flag) {
                      headdata.unshift(t1);
                    }
                  });
                }
                // console.log(headdata, "conditionList");
                headdata.forEach((q) => {
                  q.taskNo = this.taskinfo2.taskNo;
                  if (q.headType == "0") {
                    q.divisorIdentify = null;
                  }
                });
                // console.log(values, "values");
                values = this.validForm(values);
                values.forEach((t) => {
                  t.taskNo = this.taskinfo2.taskNo;
                  if (t.decisionCode != "RCODE" && t.decisionCode != "RNAME") {
                    t.decisionCode = t.divisorIdentify;
                  } else {
                    t.divisorIdentify = null;
                  }
                  if (t.divisorMethodParams && t.divisorMethodParams.length) {
                    t.methodParams = t.divisorMethodParams;
                  }
                });
                // console.log(headdata, this.headdata, "headdata");
                let heads = [];
                this.headdata.forEach((e) => {
                  if (e.decisionCode == "RNAME" || e.decisionCode == "RCODE") {
                    e.divisorIdentify = "";
                  }
                });

                if (this.echoMenulds.indexOf(this.dataForm.menuId) === -1) {
                  heads = headdata;
                } else {
                  heads = this.headdata;
                }
                let param = {
                  menuId: `${this.dataForm.menuId}`,
                  riskInfo: JSON.stringify(riskInfo),
                  heads: JSON.stringify(heads),
                  values: JSON.stringify(values),
                  delValue: JSON.stringify(delList),
                };
                // console.log(values, "223");
                this.saveRiskRule(param);
              }
            });
          } else {
            this.$message.error("请先选择配置！");
            return;
          }
        }
      });
    },
    // 删除
    delDecision(value) {
      // console.log(value, this.conditionList, "22value");
      let delList = [];
      this.conditionList.forEach((item) => {
        if (value[item.divisorIdentify] && value[item.divisorIdentify].id) {
          delList.push(value[item.divisorIdentify]);
        }
      });
      // console.log(delList);
      let riskInfo = {
        id: this.dataForm2.id,
        riskCode: this.dataForm.riskCode,
        taskNo: this.taskinfo2.taskNo,
        itemType: this.dataForm2.itemType,
      };
      let values = [];
      // console.log(this.tableDatas, "2222");
      let tableDatas = [];
      this.tableDatas.forEach((t) => {
        for (const key in t) {
          if (key != "RNAME" && key != "RCODE") {
            t[key].decisionCode = t[key].divisorIdentify;
            tableDatas.push(t[key]);
          } else {
            t[key].divisorIdentify = null;
            tableDatas.push(t[key]);
          }
        }
      });
      this.headdata.forEach((e) => {
        if (e.decisionCode == "RNAME" || e.decisionCode == "RCODE") {
          e.divisorIdentify = "";
        }
      });
      let param = {
        menuId: `${this.dataForm.menuId}`,
        riskInfo: JSON.stringify(riskInfo),
        heads: JSON.stringify(this.headdata),
        values: JSON.stringify(tableDatas),
        delValue: JSON.stringify(delList),
      };
      this.saveRiskRule(param);
    },
    // 保存请求
    saveRiskRule(param) {
      saveRiskRule(param)
        .then((res) => {
          if (res.data.resultCode === 0) {
            this.$message.success(res.data.resultMsg);
            this.getcheckRuleGroup();
            // console.log(this.istable, "this.istable");
            this.updatetable();
          } else {
            this.$message.error(res.data.resultMsg);
          }
        })
        .catch((err) => {
          this.$message.error("保存失败！");
        });
    },
    // tree传标题
    editTitile(data) {
      // console.log(data.menuId, this.dyform.addsubdataForm, "2222");
      this.ruleTitle = data.menuName;
      this.dyform.addsubdataForm.forEach((e) => {
        if (e.headType === "0" && e.decisionCode === "RNAME") {
          e.conditionDesc = "";
        }
      });
      this.resetrule();
      this.groupIdentifys = [];
      this.dataForm.menuId = data.menuId;
      if (data.groupIdentifys) {
        this.dataForm.groupIdentify = data.groupIdentifys.split(",");
        // console.log(this.dataForm.groupIdentify, "groupIdentify");
        // if (this.$route.params.id) {
        let param = {
          groupIdentify: this.dataForm.groupIdentify,
          taskNo: this.taskinfo2.taskNo || "",
          riskCode: this.dataForm.riskCode,
        };
        this.getList(param);
        // }
      } else {
        this.dataForm.groupIdentify = "";
      }
      let params = {
        groupIdentify: this.dataForm.groupIdentify,
        conditionDesc: "",
        taskNo: this.taskinfo2.taskNo,
      };
      this.getparamConfigData(params);
    },
    // 是否执行
    changeExeType(item, index, items) {
      // console.log(item, index, items);
      // this.$set(item, "isExcute", item.isExcute);
      if (this.headdatainit.length) {
      } else {
        this.changerules(item);
      }
      this.$forceUpdate();
    },
    //获取实体属性
    getItems(rightEntityId) {
      let params = {
        id: rightEntityId + "",
      };
      let name = rightEntityId + "list";
      let arr = [];
      entityItemList(params).then((res) => {
        if (res.data.data) {
          res.data.data.forEach((item) => {
            item["label"] = item.itemName + "--" + item.itemIdentify;
            arr.push(item);
          });
          this.childList[name] = arr;
          this.$forceUpdate();
          // console.log(this.childList);
        }
      });
    },
    ischangerules(data) {
      if (this.isaddLine || this.isEditLine) {
      } else {
        this.changerules(data);
      }
    },
    // 记录输入的值
    insertV(type, data, val) {
      // console.log(type, data, val);

      //规则因子 输入值
      if (type === "41") {
        data.descData[0] = { k: data.rightValue, v: data.rightValue };
        if (data.rightValue) {
          data.isExcute = "Y";
          // console.log(this.isaddLine, this.isEditLine, "22");
          this.ischangerules(data);
        } else {
          data.isExcute = "N";
        }
      }
      //枚举
      if (type === "42") {
        data.descData[0] = { k: data.enumValue, v: data.enumCode };
        data.isExcute = val.label;
        if (data.rightValue) {
          this.ischangerules(data);
        }
      }
      //模型
      if (type === "43") {
        data.descData[0] = {
          k: val.entityName + " 的",
          v: "$" + val.entityIdentify + ".",
        };
        // console.log(val.entityId);
        this.getItems(val.entityId);
        if (data.rightEntityId) {
          this.ischangerules(data);
        }
        if (data.rightProperty) {
          data.isExcute = "Y";
        }
      }
      //属性
      if (type === "44") {
        let s =
          val.itemIdentify.substring(0, 1).toLocaleUpperCase() +
          val.itemIdentify.substring(1, val.itemIdentify.length);
        let v = "get" + s + "()";
        data.descData[1] = { k: val.itemName, v: v };
        if (data.rightProperty) {
          data.isExcute = "Y";
          this.ischangerules(data);
        }
      }
      if (type === "45") {
        // 规则因子 输入值
        data.isExcute = "Y";
        data.descData = [];
        data.descData[0] = { k: val.name, v: val.name };
        if (val.name && !this.isEditLine) {
          this.ischangerules(data);
        }
      }
      data.remark = data.descData;
      // console.log(type, data, val);
    },
    //
    changerules(data) {
      // console.log(data, "data");
      // let ruleNames = [];
      let configData = [];
      let groupIdentifys = [];
      // 是否过滤
      if (this.groupIdentifys.length) {
        let ts = [];
        this.groupIdentifys.forEach((w) => {
          this.paramData.forEach((u) => {
            if (u.groupIdentify === w) {
              const paramData = u;
              ts = ts.concat(paramData);
            }
          });
          ts.forEach((p) => {
            if (p.baseList.length) {
              const paramData = p.baseList;
              paramData.forEach((e) => {
                if (e.divisorIdentify == data.divisorIdentify) {
                  groupIdentifys.push(p.groupIdentify);
                  configData = configData.concat(paramData);
                }
              });
            }
          });
        });
      } else {
        // 过滤出有该条件/动作的规则组
        // 获取过滤后的规则组的配置信息
        // console.log(this.paramData, "paramData");
        this.paramData.forEach((y) => {
          if (y.baseList.length) {
            const paramData = y.baseList;
            paramData.forEach((e) => {
              if (e.divisorIdentify == data.divisorIdentify) {
                // ruleNames.push({ value: y.groupIdentify, label: y.groupName });
                groupIdentifys.push(y.groupIdentify);
                configData = configData.concat(paramData);
              }
            });
          }
        });
      }
      this.groupIdentifys = Array.from(new Set(groupIdentifys));
      // console.log(configData, this.dyform.addsubdataForm, "223");
      this.dyform.addsubdataForm.forEach((r) => {
        r.disabled = true;
        if (r.decisionCode != "RNAME") {
          configData.forEach((t) => {
            if (r.divisorIdentify === t.divisorIdentify) {
              r.disabled = false;
            }
          });
        } else {
          r.groupIdentify = data.groupIdentify;
          r.disabled = false;
        }
      });
      // console.log(this.dyform.addsubdataForm, "adddataForm");
      // 过滤表单多余表头
      this.dyform.addsubdataForm.forEach((e) => {
        this.ruleNames.forEach((t) => {
          if (e.decisionCode == "RNAME" && e.groupIdentify === t.value) {
            e.conditionDesc = this.ruleNames[0].label;
          }
        });
      });
    },
    // 参数
    handleChange(value, direction, movedKeys) {
      // console.log(value, direction, movedKeys);
      this.tranrightvalue = value;
    },
    // 刷新表格/表单数据
    updatetable(isupdateAdd) {
      let params = {
        taskNo: this.taskinfo2.taskNo || "",
        riskCode: this.dataForm.riskCode,
        groupIdentify: this.dataForm.groupIdentify,
      };
      this.resetrule();
      getByTaskHeder(params).then((res) => {
        // console.log(res.data);
        if (res.data.data) {
          let data = res.data.data;
          let header = data.header;
          this.headdatainit = JSON.parse(JSON.stringify(header));
          this.headdata = header.slice(0);
          this.ruleNames = [];
          header.forEach((e) => {
            if (e.decisionCode == "RNAME") {
              e.divisorIdentify = "RNAME";
            }
            if (e.decisionCode == "RCODE") {
              e.divisorIdentify = "RCODE";
            }
          });
          header = insure.quchong(header, "divisorIdentify");

          // console.log(header, "heade");
          let info = data.info;
          let body = [];
          info.forEach((ele, index) => {
            if (ele) {
              this.ruleNames.push({
                label: ele.groupName,
                value: ele.groupIdentify,
              });
              body = body.concat(ele.body);
            }
          });
          let tableDatas = [];
          body.forEach((element, index) => {
            tableDatas[index] = {};
            for (const key2 in element) {
              if (key2 === "RCODE" || key2 === "RNAME") {
                element[key2]["divisorIdentify"] = key2;
                tableDatas[index][key2] = element[key2];
              } else {
                if (key2 && element[key2] && element[key2]["divisorIdentify"]) {
                  let divisorIdentifyw = element[key2]["divisorIdentify"];
                  tableDatas[index][divisorIdentifyw] = element[key2];
                }
              }
            }
          });

          // console.log(this.ruleNames, tableDatas, "this.ruleNames");
          if (body.length <= 1 && !isupdateAdd) {
            this.istable = false;
            this.isCard = true;
          } else {
            this.istable = true;
            this.isCard = false;
          }
          if (body.length && header.length) {
            let datae = JSON.parse(JSON.stringify(tableDatas[0]));
            this.dyform.addsubdataForm = this.getformdata(header, datae);
            this.initdataform = JSON.parse(
              JSON.stringify(this.dyform.addsubdataForm)
            );
            this.tableDatas = tableDatas;
            this.tableDatas.forEach((k) => {
              for (const key2 in k) {
                if (key2 === "RNAME") {
                  let groupIdentify = k[key2].groupIdentify;
                  // console.log(groupIdentify, "groupIdentify");
                  k[key2].conditionDesc = constant.getLabel(
                    groupIdentify,
                    this.ruleNames
                  );
                }
              }
            });
            this.conditionList = header;
          }
        } else {
          this.$message.error("请先添加参数配置并保存！");
        }
      });
    },
    // 新增
    updateAdd() {
      // console.log(this.headdata, "this.headdata");
      this.isaddLine = true;
      // console.log(this.istable, this.ruleNames, "ruleNames");
      if (!this.istable) {
        this.updatetable(true);
      } else {
        this.isCard = true;
        let value = [];
        if (this.tableDatas.length) {
          value = this.tableDatas[this.tableDatas.length - 1];
        } else {
          value = this.tableDatas[0];
        }
        this.groupIdentifys = [value["RNAME"].groupIdentify];
        this.dyform.addsubdataForm = this.getformdata(
          this.conditionList,
          value,
          "add"
        );
        // console.log(this.dyform.addsubdataForm);
      }
    },
    // 获取实体类的属性
    getEntityProperties(entityId) {
      entityList({}).then((res) => {
        if (res.data.data) {
          this.entitysProperties = [];
          res.data.data.forEach((item) => {
            item["label"] = item.entityIdentify + " -- " + item.entityName;
            this.entitysProperties.push(item);
            this.checkEntity.push(item);
          });
        }
      });
    },
    // 参数配置展开
    paramConfig() {
      if (this.dataForm.groupIdentify) {
        let params = {
          groupIdentify: this.dataForm.groupIdentify,
          conditionDesc: "",
          taskNo: this.taskinfo2.taskNo,
        };
        this.getparamConfigData(params);
      } else {
        this.$message.error("该菜单类型为目录，没有配置参数！");
        return;
      }
      this.configvisible = true;
    },
    // 获取配置参数
    getparamConfigData(params) {
      this.tranvalue = [];
      this.tranrightvalue = [];
      this.trandata = [];
      baseHeder(params)
        .then((res) => {
          this.$store.dispatch("loading/CHANGE_LOADING", false);
          // console.log(res, "res");
          if (res.data.resultCode === 0) {
            let data = res.data.data;
            this.paramData = JSON.parse(JSON.stringify(res.data.data));
            // console.log(data, "data");
            if (data) {
              let trandata = [];
              data.forEach((e) => {
                if (e.baseList && e.baseList.length) {
                  trandata = trandata.concat(e.baseList);
                }
              });
              this.trandata = insure.quchong(trandata, "divisorId");
            }
            // console.log(
            //   this.trandata,
            //   this.dyform.addsubdataForm,
            //   "this.trandata"
            // );
            let tranw = [];
            // console.log(this.istable);
            if (this.istable) {
              tranw = constant.getArrDifSameValue(
                this.trandata,
                this.conditionList
              );
            } else {
              tranw = constant.getArrDifSameValue(
                this.trandata,
                this.dyform.addsubdataForm
              );
            }
            // console.log(tranw, "tranw");
            this.trandata.forEach((e) => {
              tranw.forEach((t) => {
                if (e.divisorIdentify === t.divisorIdentify) {
                  this.tranvalue.push(e.id);
                }
              });
            });
            this.tranrightvalue = Array.from(new Set(this.tranvalue));
          } else if (res.data.resultCode == 500) {
            this.$message.error(res.data.resultMsg);
          }
          //   this.trandata.forEach((e) => {});
          // console.log(this.tranrightvalue, "2223");
        })
        .catch((err) => {
          this.$store.dispatch("loading/CHANGE_LOADING", false);
        });
    },

    //初始化行数据 dataForm 数据 ，item 头部信息,headType条件、动作
    setInitData(dataForm, noquest) {
      //如果是因子
      if (dataForm && dataForm.conditionType === "4") {
        let parms = { id: dataForm.divisorId };
        if (dataForm.headType === "1") {
          this.conditionDivisorList.forEach((item) => {
            if (item.id === dataForm.divisorId) {
              dataForm.divisor = item;
              if (dataForm.divisor.methodParams) {
                if (dataForm.methodParams) {
                  dataForm.divisorMethodParams = JSON.parse(
                    dataForm.methodParams
                  );
                  if (noquest == "changecard") {
                    let conditionDesc = dataForm.conditionDesc.split(",");
                    dataForm.divisorMethodParams.forEach((p, index) => {
                      if (p.value && p.value === "2") {
                        p.name = conditionDesc[index];
                      } else {
                        p.name = dataForm.conditionDesc;
                      }
                    });
                  }
                } else {
                  dataForm.divisorMethodParams = JSON.parse(
                    dataForm.divisor.methodParams
                  );
                }
              } else {
                dataForm.divisorMethodParams = "";
              }
              if (dataForm.divisor.divisorType === "1") {
              } else if (dataForm.divisor.divisorType === "0") {
                // 输入值
                if (dataForm.divisor.valueType === "2") {
                }
                //模型
                if (dataForm.divisor.itemValueType === "3") {
                  if (dataForm.rightEntityId) {
                    this.getItems(dataForm.rightEntityId);
                  }
                }
              }
            }
          });
          if (dataForm.divisor && dataForm.divisor.itemValueType === "2") {
            let name = dataForm.divisor.id + "list";
            let arr = [];
            getData(parms).then((res) => {
              res.data.data.enumList.forEach((item) => {
                item["label"] = item.enumCode + "--" + item.enumValue;
                arr.push(item);
              });
              this.enumList[name] = arr;
              // console.log(this.enumList);
            });
          }
        }
        if (dataForm.headType === "2") {
          this.actionDivisorList.forEach((item) => {
            if (item.id === dataForm.divisorId) {
              dataForm.divisor = item;
              if (dataForm.divisor && dataForm.divisor.divisorType === "1") {
                let param;
                if (dataForm.conditionDesc) {
                  param = dataForm.conditionDesc.split(",");
                  if (dataForm.divisor.methodParams) {
                    dataForm.divisorMethodParams = JSON.parse(
                      dataForm.divisor.methodParams
                    );
                    if (dataForm.divisorMethodParams.length > 1) {
                      dataForm.divisorMethodParams.forEach((p, index) => {
                        p.name = param[index];
                      });
                    } else {
                      dataForm.divisorMethodParams[0].name = param;
                    }
                  }
                } else {
                  dataForm.divisorMethodParams = JSON.parse(
                    dataForm.divisor.methodParams
                  );
                }
              } else if (dataForm.divisor.divisorType === "0") {
                // 输入值
                if (dataForm.divisor.valueType === "2") {
                  // dataForm.showTxt = true;
                }
                //模型
                if (dataForm.divisor.itemValueType === "3") {
                  if (dataForm.rightEntityId) {
                    this.getItems(dataForm.rightEntityId);
                  }
                }
              }
            }
          });
          if (dataForm.divisor && dataForm.divisor.itemValueType === "2") {
            let name = dataForm.divisor.id + "list";
            let arr = [];
            getActionData(parms).then((res) => {
              res.data.data.enumList.forEach((item) => {
                item["label"] = item.enumCode + "--" + item.enumValue;
                arr.push(item);
              });
              this.actionEnumList[name] = arr;
            });
          }
        }
        // if (!noquest) {
        dataForm = this.getparamconfig(dataForm);
        // }
      }
      return dataForm;
    },
    // 请求方法参数配置
    getparamconfig(dataForm, initadd) {
      if (
        dataForm.divisor &&
        dataForm.divisor.divisorType === "1" &&
        dataForm.methodParams
      ) {
        if (dataForm.divisorMethodParams && initadd) {
          dataForm.divisorMethodParams.forEach((e) => {
            if (e && e.name) {
              e.name = "";
            }
          });
        }
        dataForm.showMthod = true;
        dataForm.divisormethodEnum = [];
        let methodParams = JSON.parse(dataForm.methodParams);
        let divisormethodParams = JSON.parse(dataForm.divisor.methodParams);
        methodParams.forEach(async (e, i) => {
          dataForm.divisormethodEnum[i] = [];
          if (e.valueType === "2") {
            let parms = {
              divisor_identify:
                dataForm.divisorIdentify || dataForm.divisor.divisorIdentify,
              param_name: divisormethodParams[i].name,
            };
            await getEnum(parms).then(({ data }) => {
              if (data.resultCode === 0) {
                data.data.forEach((item) => {
                  item["label"] = item.enumCode + "--" + item.enumValue;
                  item["value"] = item.enumCode;
                  dataForm.divisormethodEnum[i].push(item);
                });
              }
              return dataForm;
            });
            this.$forceUpdate();
          }
        });
      }
      return dataForm;
    },
    // 配置保存
    configSubmit() {
      // 选中的对象
      // console.log(
      //   this.tranrightvalue,
      //   this.dyform.addsubdataForm,
      //   "this.tranrightvalue"
      // );
      let trans = [];
      // 选中的表头
      this.trandata.forEach((e) => {
        this.tranrightvalue.forEach((k) => {
          if (e.id === k) {
            trans.push(e);
          }
        });
      });
      let addtrans = [];
      // 与表单对比补全该行
      if (this.isCard) {
        trans.forEach((t) => {
          let flag = false;
          this.dyform.addsubdataForm.forEach((a2) => {
            if (t.divisorIdentify == a2.divisorIdentify) {
              flag = true;
            }
          });
          if (!flag) {
            addtrans.push(t);
          }
        });
      } else {
        // console.log(this.conditionList, "conditionList");
        trans.forEach((t) => {
          let flag = false;
          this.conditionList.forEach((a2) => {
            if (t.divisorIdentify == a2.divisorIdentify) {
              flag = true;
            }
          });
          if (!flag) {
            addtrans.push(t);
          }
        });
      }
      // console.log(addtrans, "addtrans");
      // 新增
      if (addtrans.length) {
        // 卡片
        addtrans.forEach((k) => {
          let data = JSON.parse(JSON.stringify(this.setInitData(k, "noquest")));
          data = this.getparamconfig(data, "initadd");
          this.$nextTick(() => {
            // 初始化表单
            data.descData = new Array();
            data.id = null;
            data.isExcute = "";
            data.rightValue = "";
            data.rightEntityId = "";
            data.rightProperty = "";
            data.disabled = false;
            // data.descData = JSON.parse(data.remark);
            this.dyform.addsubdataForm.push(data);
            this.headdata.push(data);
            if (
              this.echoMenulds.indexOf(this.dataForm.menuId) != -1 &&
              this.conditionList.length
            ) {
              // 表格
              let found = this.ruleNames.some(
                (el) => el.value === data.groupIdentify
              );
              // console.log(this.paramData, "this.paramData");
              // console.log(this.ruleNames, found, "ruleNames");
              if (!found) {
                this.paramData.forEach((r) => {
                  if (r.groupIdentify == data.groupIdentify) {
                    this.ruleNames.push({
                      value: data.groupIdentify,
                      label: r.groupName,
                    });
                  }
                });
              }
            }
            this.dyform.addsubdataForm = this.handleaddsubdataForm(
              this.dyform.addsubdataForm
            );
            if (
              !this.dyform.addsubdataForm.filter(
                (item) => item["decisionCode"] == "RNAME"
              ).length
            ) {
              this.dyform.addsubdataForm.unshift(this.initadd.RNAME);
            }
            this.getRuleName();
          });
        });
        this.configvisible = false;
        if (
          this.echoMenulds.indexOf(this.dataForm.menuId) != -1 &&
          this.conditionList.length
        ) {
          this.$nextTick(() => {
            this.ruleNames = insure.quchong(this.ruleNames, "value");
            let head = this.headdata.slice(0);
            let groupIdentifys = [];
            head.forEach((t) => {
              if (t.headType == 0) {
                t.divisorIdentify = null;
                let flag = false;
                this.ruleNames.forEach((k) => {
                  if (t.groupIdentify == k.value) {
                    flag = true;
                  }
                });
                if (!flag) {
                  groupIdentifys.push(t.groupIdentify);
                }
              }
            });
            groupIdentifys = Array.from(new Set(groupIdentifys));
            groupIdentifys.forEach((y) => {
              let initadd = JSON.parse(JSON.stringify(this.initadd));
              initadd.RCODE.groupIdentify = y;
              initadd.RNAME.groupIdentify = y;
              head.unshift(initadd.RCODE);
              head.unshift(initadd.RNAME);
            });
            let tableDatas = [];
            this.tableDatas.forEach((t) => {
              for (const key in t) {
                if (key != "RNAME" && key != "RCODE") {
                  t[key].decisionCode = t[key].divisorIdentify;
                  tableDatas.push(t[key]);
                } else {
                  t[key].divisorIdentify = null;
                  tableDatas.push(t[key]);
                }
              }
            });
            let riskInfo = {
              id: this.dataForm2.id,
              riskCode: this.dataForm.riskCode,
              taskNo: this.taskinfo2.taskNo,
              itemType: this.dataForm2.itemType,
            };
            // console.log(head, "this.headdata");
            let param = {
              menuId: `${this.dataForm.menuId}`,
              riskInfo: JSON.stringify(riskInfo),
              heads: JSON.stringify(head),
              values: JSON.stringify(tableDatas),
              delValue: JSON.stringify([]),
            };
            this.saveRiskRule(param);
          });
        }
      } else {
        // 减少
        let reducttrans = [];
        // 与表单对比缺少
        // console.log(this.headdata, "this.headdata");
        // if (this.echoMenulds.indexOf(this.dataForm.menuId) == -1) {
        // 未配置过不需要请求保存接口
        this.dyform.addsubdataForm.forEach((d) => {
          if (d.headType != 0) {
            trans.forEach((t) => {
              if (d.divisorIdentify == t.divisorIdentify) {
                reducttrans.push(d);
              }
            });
          } else {
            reducttrans.push(d);
          }
        });
        // console.log(reducttrans);
        this.dyform.addsubdataForm = reducttrans;
        // }
        // console.log(this.ruleNames, "this.ruleNames");
        // 除去表头多出项,除去表单多出项
        let head = [];
        let head0 = [];
        let delValue = [];
        let tableDatas = [];
        if (trans.length) {
          this.headdata.forEach((d) => {
            if (d.headType == 0) {
              d.divisorIdentify = null;
              head.push(d);
            } else {
              trans.forEach((t) => {
                if (d.divisorIdentify == t.divisorIdentify) {
                  head.push(d);
                  head0.push(d.groupIdentify);
                }
              });
            }
          });
          head0 = Array.from(new Set(head0));
          // let groupIdentifys = [];
          let ruleNames = [];
          // 已从配置中去除的规则组
          this.ruleNames.forEach((t) => {
            ruleNames.push(t.value);
          });
          let groupIdentifys = ruleNames.filter((items) => {
            if (!head0.includes(items)) return items;
          });
          // console.log(groupIdentifys, "groupIdentifys");
          if (groupIdentifys.length) {
            let headdata = [];
            head.forEach((ele, index) => {
              groupIdentifys.forEach((k) => {
                if (ele.headType == 0) {
                  if (ele.groupIdentify != k) {
                    headdata.push(ele);
                  }
                } else {
                  headdata.push(ele);
                }
              });
            });
            head = headdata;
          }
          // console.log(head, "head");
          this.tableDatas.forEach((t) => {
            for (const key in t) {
              if (key != "RNAME" && key != "RCODE") {
                t[key].decisionCode = t[key].divisorIdentify;
                let flag = false;
                trans.forEach((s) => {
                  if (key === s.divisorIdentify) {
                    tableDatas.push(t[key]);
                    flag = true;
                  }
                });
                if (!flag) {
                  delValue.push(t[key]);
                  delete t[key];
                }
              } else {
                tableDatas.push(t[key]);
                t[key].divisorIdentify = null;
              }
            }
          });
        } else {
          // 配置为空，表格table全部删除
          this.tableDatas.forEach((t) => {
            for (const key in t) {
              if (key != "RNAME" && key != "RCODE") {
                t[key].decisionCode = t[key].divisorIdentify;
                delValue.push(t[key]);
              } else {
                t[key].divisorIdentify = null;
                delValue.push(t[key]);
              }
            }
          });
          this.tableDatas = [];
          this.dyform.addsubdataForm = [];
        }
        // console.log(this.headdata, this.tableDatas, delValue, "head");
        if (
          this.echoMenulds.indexOf(this.dataForm.menuId) != -1 &&
          this.conditionList.length
        ) {
          // 已配置过需请求保存接口
          this.$confirm(`确定进行[保存]操作`, "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }).then(() => {
            let riskInfo = {
              id: this.dataForm2.id,
              riskCode: this.dataForm.riskCode,
              taskNo: this.taskinfo2.taskNo,
              itemType: this.dataForm2.itemType,
            };
            // console.log(this.headdata, "this.headdata");
            let param = {
              menuId: `${this.dataForm.menuId}`,
              riskInfo: JSON.stringify(riskInfo),
              heads: JSON.stringify(head),
              values: JSON.stringify(tableDatas),
              delValue: JSON.stringify(delValue),
            };
            this.saveRiskRule(param);
            this.configvisible = false;
          });
        } else {
          this.configvisible = false;
        }
        this.getRuleName();
      }
    },
    // 从表单根据headType、divisorId确定选中的配置包含在哪几个规则组内，并作为this.ruleNames（总规则组）

    getRuleName() {
      let ruleNames = [];
      this.initHead = [];
      // 从配置内筛选出规则组
      this.paramData.forEach((e) => {
        if (e.baseList.length) {
          const paramData = e.baseList;
          paramData.forEach((k) => {
            this.dyform.addsubdataForm.forEach((t) => {
              if (t.divisorIdentify == k.divisorIdentify) {
                ruleNames.push({
                  value: e.groupIdentify,
                  label: e.groupName,
                });
                this.initHead.push(e.groupIdentify);
              }
            });
          });
        }
      });
      this.initHead = Array.from(new Set(this.initHead));
      this.ruleNames = insure.quchong(ruleNames, "value");
    },
    // 是否显示Y/N下拉框
    handleaddsubdataForm(data) {
      data.forEach((e) => {
        if (!e.divisor) {
          e.iszhixing = false;
        } else {
          // 非方法，固定值
          if (e.divisor && e.divisor.divisorType == "0") {
            if (!e.divisor.valueType || e.divisor.valueType == "1") {
              e.iszhixing = true;
            } else {
              e.iszhixing = false;
            }
          } else if (e.divisor && e.divisor.divisorType == "1") {
            // 方法
            if (e.divisor.methodParams) {
              let param = JSON.parse(e.divisor.methodParams);
              if (param.length) {
                e.iszhixing = false;
              } else {
                e.iszhixing = true;
              }
            } else {
              e.iszhixing = true;
            }
          }
        }
      });
      return data;
    },
    //校验数据
    validForm(values) {
      for (let i = 0; i < values.length; i++) {
        let dataForm = values[i];
        if (
          dataForm.headType != "0" &&
          dataForm.conditionType == "4" &&
          dataForm.divisor &&
          !dataForm.iszhixing
        ) {
          if (dataForm.divisor.divisorType === "0") {
            // 非方法 输入值 枚举值
            if (
              dataForm.divisor.itemValueType === "1" ||
              dataForm.divisor.itemValueType === "2"
            ) {
              if (dataForm.rightValue) {
                dataForm.isExcute = "Y";
              } else {
                dataForm.isExcute = "N";
              }
            }
            // 非方法 模型属性
            if (dataForm.divisor.itemValueType === "3") {
              if (dataForm.rightEntityId) {
                dataForm.isExcute = "Y";
              } else {
                dataForm.isExcute = "N";
              }
            }
          }
          // 方法
          if (
            dataForm.divisor.divisorType === "1" &&
            dataForm.divisorMethodParams
          ) {
            if (dataForm.divisorMethodParams.length > 0) {
              let num = 0;
              for (let j = 0; j < dataForm.divisorMethodParams.length; j++) {
                let item = dataForm.divisorMethodParams[j];
                let value = item.name;
                if (value) {
                  num++;
                }
              }
              //如果参数都填 默认执行
              if (num == dataForm.divisorMethodParams.length) {
                dataForm.isExcute = "Y";
              } else {
                dataForm.isExcute = "N";
              }
            }
          }
          if (dataForm.iszhixing) {
            dataForm.isExcute = dataForm.isExcute;
          }
        }
      }
      return values;
    },
    configvalid() {
      if (this.asidemenu.every((target) => target.icon === "true")) {
        this.$router.push({
          path: "/drools-ruleConfig/zerenrules/insurance-rules",
        });
      } else {
        this.$message.error("请配置完全部的规则导航类型！");
      }
    },
    // 表单提交
    contentSubmit() {
      // console.log(this.asidemenu, "this.asidemenu");
      this.configvalid();
      // let param = {
      //   id: this.dataForm.id || "",
      //   riskCode: this.dataForm.riskCode,
      //   taskNo: this.taskinfo2.taskNo,
      //   itemType: this.dataForm2.itemType,
      //   riskType: this.dataForm2.riskType,
      //   // configType: this.dataForm2.configType,
      //   isComplete: "Y",
      // };
      // updateComplete(param).then((res) => {
      //   if (res.data.resultCode === 0) {
      // this.$message.success(res.data.resultMsg);
      // this.$router.push({
      //   path: "/drools-ruleConfig/zerenrules/insurance-rules",
      // });
      //   } else {
      //     this.$message.error(res.data.resultMsg);
      //   }
      // });
    },
    // 返回险种首页
    toList() {
      if (!this.isShow) {
        this.configvalid();
      }
      if (this.$route.query.isShow) {
        this.$router.push({
          path: "/drools-ruleConfig/zerenrules/insurance-rules",
        });
      }
    },
    // 公式配置确定
    FormulaSubmit() {},
    // 最终赋值
    // dataFrom=>values
    setValueData(dataFrom) {
      dataFrom.remark = JSON.stringify(dataFrom.descData);
      if (dataFrom.conditionType === "4") {
        //因子
        if (dataFrom.isExcute === "Y") {
          //非方法
          if (dataFrom.divisor && dataFrom.divisor.divisorType === "0") {
            //因子类型为输入值
            if (dataFrom.divisor.valueType === "2") {
              if (dataFrom.divisor.itemValueType != "3") {
                //非模型
                dataFrom.conditionDesc = dataFrom.rightValue;
                dataFrom.decisionExp =
                  dataFrom.conditionExpression + dataFrom.rightValue;
              } else {
                this.showValue(dataFrom);
              }
            } else {
              //固定值
              dataFrom.conditionDesc = dataFrom.isExcute;
              dataFrom.decisionExp = dataFrom.conditionExpression;
            }
          } else {
            //方法参数处理
            if (dataFrom.divisorMethodParams) {
              let inputValue = "";
              let newValue = "";
              if (dataFrom.headType == "1") {
                newValue = "ClmUtil." + dataFrom.divisor.divisorMethod;
              } else {
                newValue = "ActionUtil." + dataFrom.divisor.divisorMethod;
              }

              for (var j = 0; j < dataFrom.divisorMethodParams.length; j++) {
                let value = dataFrom.divisorMethodParams[j].name;
                let params = dataFrom.divisorMethodParams[j].attri; //参数名称

                inputValue += value + ",";
                let p = "$" + params + "$";
                if (dataFrom.divisorMethodParams[j].type === "String") {
                  newValue = newValue.replace(p, '"' + value + '"');
                } else {
                  newValue = newValue.replace(p, value);
                }
              }
              inputValue = inputValue.substring(0, inputValue.length - 1);
              dataFrom.conditionDesc = inputValue;
              dataFrom.decisionExp = newValue;
              dataFrom.methodParams = JSON.stringify(
                dataFrom.divisorMethodParams
              );
            } else {
              dataFrom.conditionDesc = dataFrom.isExcute;
              dataFrom.decisionExp = dataFrom.conditionExpression;
            }
          }
        } else if (dataFrom.isExcute === "N") {
          dataFrom.conditionDesc = dataFrom.isExcute;
          //非方法
          if (dataFrom.divisor.divisorType === "0") {
            //因子类型为输入值
            if (dataFrom.divisor.valueType === "2") {
              if (dataFrom.divisor.itemValueType != "3") {
                //非模型
                dataFrom.conditionDesc = dataFrom.rightValue;
                dataFrom.decisionExp =
                  dataFrom.conditionExpression + dataFrom.rightValue;
              } else {
                this.showValue(dataFrom);
              }
            } else {
              //固定值
              dataFrom.conditionDesc = dataFrom.isExcute;
              dataFrom.decisionExp = dataFrom.conditionExpression;
            }
          } else {
            //方法参数处理
            if (dataFrom.divisorMethodParams) {
              let inputValue = "";
              let newValue = "";
              if (dataFrom.headType == "1") {
                newValue = "ClmUtil." + dataFrom.divisor.divisorMethod;
              } else {
                newValue = "ActionUtil." + dataFrom.divisor.divisorMethod;
              }
              dataFrom.conditionDesc = inputValue;
              dataFrom.decisionExp = newValue;
              dataFrom.methodParams = JSON.stringify(
                dataFrom.divisorMethodParams
              );
            } else {
              dataFrom.conditionDesc = dataFrom.isExcute;
              dataFrom.decisionExp = dataFrom.conditionExpression;
            }
          }
        } else {
          dataFrom.conditionDesc = dataFrom.isExcute;
        }
      }
    },
    // 显示描述信息
    showValue(dataForm) {
      dataForm.conditionExpression = "";
      dataForm.conditionDesc = "";
      if (dataForm.rightValue == null) {
        dataForm.rightValue = "";
      }
      dataForm.descData.forEach((item) => {
        if (item.v && item.k) {
          dataForm.conditionExpression =
            dataForm.conditionExpression + item.v + dataForm.rightValue;
          dataForm.conditionDesc =
            dataForm.conditionDesc + item.v + dataForm.rightValue;
        }
      });
    },
  },
  filters: {
    insureFormat: function (value) {
      return constant.getLabel(value, insure.insurenceTyoe);
    },
  },
};
</script>

<style lang="less" scoped>
.xinput {
  // width: 100%;
  height: 80px;
  border: 1px solid #f0f0f0;
  margin: 10px;
  border-bottom: 0px;
}
.expandline {
  width: 100%;
  height: 1px;
  background-color: #e1e1e1;
}
.cont-a {
  line-height: 40px;
  width: 100px;
  margin-left: 20px;
  cursor: pointer;
  color: #68a3fc;
  text-decoration: underline;
}
.dingyi-footer {
  text-align: right;
}
.cont {
  min-height: 150px;
  margin-top: 20px;
  overflow: hidden;
}
.box-card {
  position: relative;
  margin: 0 20px 20px 20px;
  min-height: 200px;
}
.cont-expand {
  height: 50px;
  padding: 0 20px;
  .right {
    .el-button {
      svg {
        color: #fff;
        margin-left: 10px;
      }
    }
  }
}
.contain1 {
  height: 800px;
  padding: 20px;
  display: flex;
  .el-aside {
    background-color: #f9f9f9 !important;
    margin-right: 20px;
    border: 1px solid #e4e4e4;
    overflow: hidden !important;
    .aside-title {
      display: flex;
      background-color: #f2f2f2;
      svg {
        margin: 16px 10px 0 20px;
        width: 16px;
        height: 16px;
      }
      p {
        line-height: 50px;
      }
    }
    .asidemenu {
      height: 750px;
      overflow: auto;
    }
  }
  .el-main {
    padding: 0;
    flex: 1;
    border: 1px solid #e4e4e4;
    overflow: hidden;
    .main-title {
      display: flex;
      background-color: #f2f2f2;
      svg {
        margin: 16px 10px 0 20px;
        width: 16px;
        height: 16px;
      }
      p {
        line-height: 50px;
      }
    }
    .contant {
      .cont-text {
        height: 50px;
        padding-top: 16px;
        margin-left: 16px;
        // border-bottom: 1px solid #e4e4e4;
        .left {
          margin-top: 13px;
          height: 30px;
          line-height: 30px;
          .left-icon {
            width: 16px;
            height: 16px;
            margin-top: 3px;
            margin-right: 8px;
            svg {
              width: 16px;
              height: 16px;
            }
          }
          .gzdy {
            margin-right: 100px;
          }
          .canshu {
            color: #5d9ceb;
            cursor: pointer;
          }
        }
      }
      .cont-data {
        height: 700px;
        overflow: auto;
      }
    }
  }
}
</style>
<style lang="less">
.colwidth {
  width: auto !important;
}
.xinput {
  .el-form-item,
  .el-divider--horizontal {
    margin: 0;
  }
}
.xzlx div.el-form-item__content {
  display: flex !important;
}
#cofginpz .el-dialog {
  height: 700px !important;
  .el-dialog__header {
    border-bottom: 1px solid #e4e4e4;
  }
  .el-transfer {
    width: 100%;
    display: flex !important;
    justify-content: center;
    align-items: center;
  }
  .el-transfer-panel {
    width: 35%;
    // min-width: 400px;
    // width: 520px;
    height: 500px;
  }
  .el-transfer-panel__list.is-filterable {
    width: 100%;
    height: 330px;
  }
}
</style>